package cn.levi.path.component;

import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.levi.path.configuration.UrlProperties;
import lombok.AllArgsConstructor;

/**
 * url处理组件
 *
 * @author lei
 * @since 2024/11/26
 */
@AllArgsConstructor
public class DefaultURLPathHandler implements URLPathHandler {

	private  UrlProperties urlProperties;


	/**
	 * 拼接path->url，拼接后的url可直接访问，
	 *
	 * @return
	 */
	public  String concatUrlPrefix(String path) {
		//获取前缀
		String prefix = urlProperties.getPrefix();
		//返回拼接
		return StrUtil.prependIfMissing(path, prefix, false, "http" );
	}
}
